home *** CD-ROM | disk | FTP | other *** search
/ Motor Sport Digital Archive Collection 1960s / Motor Sport Digital Archive Collection 1960s.iso / main.swf / scripts / mx / containers / Panel.as < prev    next >
Encoding:
Text File  |  2008-05-21  |  27.0 KB  |  793 lines

  1. package mx.containers
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.display.Graphics;
  5.    import flash.events.Event;
  6.    import flash.events.MouseEvent;
  7.    import flash.geom.Rectangle;
  8.    import mx.automation.IAutomationObject;
  9.    import mx.containers.utilityClasses.BoxLayout;
  10.    import mx.containers.utilityClasses.CanvasLayout;
  11.    import mx.containers.utilityClasses.Layout;
  12.    import mx.controls.Button;
  13.    import mx.core.Container;
  14.    import mx.core.ContainerLayout;
  15.    import mx.core.EdgeMetrics;
  16.    import mx.core.EventPriority;
  17.    import mx.core.IFlexDisplayObject;
  18.    import mx.core.IUIComponent;
  19.    import mx.core.UIComponent;
  20.    import mx.core.UIComponentCachePolicy;
  21.    import mx.core.UITextField;
  22.    import mx.core.mx_internal;
  23.    import mx.effects.EffectManager;
  24.    import mx.events.CloseEvent;
  25.    import mx.styles.ISimpleStyleClient;
  26.    import mx.styles.IStyleClient;
  27.    
  28.    use namespace mx_internal;
  29.    
  30.    public class Panel extends Container
  31.    {
  32.       mx_internal static var createAccessibilityImplementation:Function;
  33.       
  34.       mx_internal static const VERSION:String = "2.0.1.0";
  35.       
  36.       private static const HEADER_PADDING:Number = 14;
  37.       
  38.       protected var statusTextField:UITextField;
  39.       
  40.       private var initializing:Boolean = true;
  41.       
  42.       private var _layout:String = "vertical";
  43.       
  44.       private var autoSetRoundedCorners:Boolean;
  45.       
  46.       private var _statusChanged:Boolean = false;
  47.       
  48.       protected var titleTextField:UITextField;
  49.       
  50.       private var _titleIconChanged:Boolean = false;
  51.       
  52.       private var _status:String = "";
  53.       
  54.       private var _title:String = "";
  55.       
  56.       private var _titleIcon:Class;
  57.       
  58.       protected var controlBar:IUIComponent;
  59.       
  60.       mx_internal var titleIconObject:Object = null;
  61.       
  62.       private var panelViewMetrics:EdgeMetrics;
  63.       
  64.       mx_internal var _showCloseButton:Boolean = false;
  65.       
  66.       private var checkedForAutoSetRoundedCorners:Boolean;
  67.       
  68.       mx_internal var titleBarBackground:IFlexDisplayObject;
  69.       
  70.       private var regX:Number;
  71.       
  72.       private var regY:Number;
  73.       
  74.       protected var titleBar:UIComponent;
  75.       
  76.       private var layoutObject:Layout;
  77.       
  78.       private var _titleChanged:Boolean = false;
  79.       
  80.       mx_internal var closeButton:Button;
  81.       
  82.       public function Panel()
  83.       {
  84.          mx_internal::_showCloseButton = false;
  85.          mx_internal::titleIconObject = null;
  86.          initializing = true;
  87.          _layout = ContainerLayout.VERTICAL;
  88.          _status = "";
  89.          _statusChanged = false;
  90.          _title = "";
  91.          _titleChanged = false;
  92.          _titleIconChanged = false;
  93.          super();
  94.          addEventListener("resizeStart",EffectManager.mx_internal::eventHandler,false,EventPriority.EFFECT);
  95.          addEventListener("resizeEnd",EffectManager.mx_internal::eventHandler,false,EventPriority.EFFECT);
  96.          layoutObject = new BoxLayout();
  97.          layoutObject.target = this;
  98.          showInAutomationHierarchy = true;
  99.       }
  100.       
  101.       [Bindable("statusChanged")]
  102.       public function get status() : String
  103.       {
  104.          return _status;
  105.       }
  106.       
  107.       public function set status(param1:String) : void
  108.       {
  109.          _status = param1;
  110.          _statusChanged = true;
  111.          invalidateProperties();
  112.          dispatchEvent(new Event("statusChanged"));
  113.       }
  114.       
  115.       mx_internal function getTitleBar() : UIComponent
  116.       {
  117.          return titleBar;
  118.       }
  119.       
  120.       protected function startDragging(param1:MouseEvent) : void
  121.       {
  122.          regX = param1.stageX - x;
  123.          regY = param1.stageY - y;
  124.          systemManager.addEventListener(MouseEvent.MOUSE_MOVE,systemManager_mouseMoveHandler,true);
  125.          systemManager.addEventListener(MouseEvent.MOUSE_UP,systemManager_mouseUpHandler,true);
  126.          systemManager.stage.addEventListener(Event.MOUSE_LEAVE,stage_mouseLeaveHandler);
  127.       }
  128.       
  129.       private function systemManager_mouseMoveHandler(param1:MouseEvent) : void
  130.       {
  131.          param1.stopImmediatePropagation();
  132.          move(param1.stageX - regX,param1.stageY - regY);
  133.       }
  134.       
  135.       public function set title(param1:String) : void
  136.       {
  137.          _title = param1;
  138.          _titleChanged = true;
  139.          invalidateProperties();
  140.          invalidateSize();
  141.          mx_internal::invalidateViewMetricsAndPadding();
  142.          dispatchEvent(new Event("titleChanged"));
  143.       }
  144.       
  145.       override mx_internal function get usePadding() : Boolean
  146.       {
  147.          return layout != ContainerLayout.ABSOLUTE;
  148.       }
  149.       
  150.       override public function getChildIndex(param1:DisplayObject) : int
  151.       {
  152.          if(Boolean(controlBar) && param1 == controlBar)
  153.          {
  154.             return numChildren;
  155.          }
  156.          return super.getChildIndex(param1);
  157.       }
  158.       
  159.       private function systemManager_mouseUpHandler(param1:MouseEvent) : void
  160.       {
  161.          if(!isNaN(regX))
  162.          {
  163.             stopDragging();
  164.          }
  165.       }
  166.       
  167.       protected function getHeaderHeight() : Number
  168.       {
  169.          var _loc1_:Number = NaN;
  170.          _loc1_ = getStyle("headerHeight");
  171.          if(isNaN(_loc1_))
  172.          {
  173.             _loc1_ = measureHeaderText().height + HEADER_PADDING;
  174.          }
  175.          return _loc1_;
  176.       }
  177.       
  178.       private function showTitleBar(param1:Boolean) : void
  179.       {
  180.          var _loc2_:int = 0;
  181.          var _loc3_:int = 0;
  182.          var _loc4_:DisplayObject = null;
  183.          titleBar.visible = param1;
  184.          _loc2_ = titleBar.numChildren;
  185.          _loc3_ = 0;
  186.          while(_loc3_ < _loc2_)
  187.          {
  188.             _loc4_ = titleBar.getChildAt(_loc3_);
  189.             _loc4_.visible = param1;
  190.             _loc3_++;
  191.          }
  192.       }
  193.       
  194.       override public function createComponentsFromDescriptors(param1:Boolean = true) : void
  195.       {
  196.          var _loc2_:IUIComponent = null;
  197.          var _loc3_:Object = null;
  198.          super.createComponentsFromDescriptors();
  199.          if(numChildren == 0)
  200.          {
  201.             setControlBar(null);
  202.             return;
  203.          }
  204.          _loc2_ = IUIComponent(getChildAt(numChildren - 1));
  205.          if(_loc2_ is ControlBar)
  206.          {
  207.             _loc3_ = _loc2_.document;
  208.             if(mx_internal::contentPane)
  209.             {
  210.                mx_internal::contentPane.removeChild(DisplayObject(_loc2_));
  211.             }
  212.             else
  213.             {
  214.                removeChild(DisplayObject(_loc2_));
  215.             }
  216.             _loc2_.document = _loc3_;
  217.             rawChildren.addChild(DisplayObject(_loc2_));
  218.             setControlBar(_loc2_);
  219.          }
  220.          else
  221.          {
  222.             setControlBar(null);
  223.          }
  224.       }
  225.       
  226.       private function measureHeaderText() : Rectangle
  227.       {
  228.          var _loc1_:Number = NaN;
  229.          var _loc2_:Number = NaN;
  230.          _loc1_ = 20;
  231.          _loc2_ = 14;
  232.          if(Boolean(titleTextField) && Boolean(titleTextField.text))
  233.          {
  234.             titleTextField.validateNow();
  235.             _loc1_ = titleTextField.textWidth;
  236.             _loc2_ = titleTextField.textHeight;
  237.          }
  238.          if(statusTextField)
  239.          {
  240.             statusTextField.validateNow();
  241.             _loc1_ = Math.max(_loc1_,statusTextField.textWidth);
  242.             _loc2_ = Math.max(_loc2_,statusTextField.textHeight);
  243.          }
  244.          return new Rectangle(0,0,Math.round(_loc1_),Math.round(_loc2_));
  245.       }
  246.       
  247.       mx_internal function getTitleTextField() : UITextField
  248.       {
  249.          return titleTextField;
  250.       }
  251.       
  252.       override protected function measure() : void
  253.       {
  254.          var _loc1_:Rectangle = null;
  255.          var _loc2_:Number = NaN;
  256.          var _loc3_:Number = NaN;
  257.          var _loc4_:EdgeMetrics = null;
  258.          var _loc5_:Number = NaN;
  259.          var _loc6_:Number = NaN;
  260.          super.measure();
  261.          layoutObject.measure();
  262.          _loc1_ = measureHeaderText();
  263.          _loc2_ = _loc1_.width;
  264.          _loc3_ = _loc1_.height;
  265.          _loc4_ = borderMetrics;
  266.          _loc2_ += _loc4_.left + _loc4_.right;
  267.          _loc5_ = 5;
  268.          _loc2_ += _loc5_ * 2;
  269.          if(mx_internal::titleIconObject)
  270.          {
  271.             _loc2_ += mx_internal::titleIconObject.width;
  272.          }
  273.          if(mx_internal::closeButton)
  274.          {
  275.             _loc2_ += mx_internal::closeButton.getExplicitOrMeasuredWidth() + 6;
  276.          }
  277.          measuredMinWidth = Math.max(_loc2_,measuredMinWidth);
  278.          measuredWidth = Math.max(_loc2_,measuredWidth);
  279.          if(Boolean(controlBar) && Boolean(controlBar.includeInLayout))
  280.          {
  281.             _loc6_ = controlBar.getExplicitOrMeasuredWidth() + _loc4_.left + _loc4_.right;
  282.             measuredWidth = Math.max(measuredWidth,_loc6_);
  283.          }
  284.       }
  285.       
  286.       mx_internal function getControlBar() : IUIComponent
  287.       {
  288.          return controlBar;
  289.       }
  290.       
  291.       mx_internal function getStatusTextField() : UITextField
  292.       {
  293.          return statusTextField;
  294.       }
  295.       
  296.       override protected function commitProperties() : void
  297.       {
  298.          super.commitProperties();
  299.          if(_titleChanged)
  300.          {
  301.             _titleChanged = false;
  302.             titleTextField.text = _title;
  303.             if(initialized)
  304.             {
  305.                layoutChrome(unscaledWidth,unscaledHeight);
  306.             }
  307.          }
  308.          if(_titleIconChanged)
  309.          {
  310.             _titleIconChanged = false;
  311.             if(mx_internal::titleIconObject)
  312.             {
  313.                titleBar.removeChild(DisplayObject(mx_internal::titleIconObject));
  314.                mx_internal::titleIconObject = null;
  315.             }
  316.             if(_titleIcon)
  317.             {
  318.                mx_internal::titleIconObject = new _titleIcon();
  319.                titleBar.addChild(DisplayObject(mx_internal::titleIconObject));
  320.             }
  321.             if(initialized)
  322.             {
  323.                layoutChrome(unscaledWidth,unscaledHeight);
  324.             }
  325.          }
  326.          if(_statusChanged)
  327.          {
  328.             _statusChanged = false;
  329.             statusTextField.text = _status;
  330.             if(initialized)
  331.             {
  332.                layoutChrome(unscaledWidth,unscaledHeight);
  333.             }
  334.          }
  335.       }
  336.       
  337.       public function set titleIcon(param1:Class) : void
  338.       {
  339.          _titleIcon = param1;
  340.          _titleIconChanged = true;
  341.          invalidateProperties();
  342.          invalidateSize();
  343.          dispatchEvent(new Event("titleIconChanged"));
  344.       }
  345.       
  346.       override protected function layoutChrome(param1:Number, param2:Number) : void
  347.       {
  348.          var _loc3_:EdgeMetrics = null;
  349.          var _loc4_:Number = NaN;
  350.          var _loc5_:Number = NaN;
  351.          var _loc6_:Number = NaN;
  352.          var _loc7_:Number = NaN;
  353.          var _loc8_:Graphics = null;
  354.          var _loc9_:Number = NaN;
  355.          var _loc10_:Number = NaN;
  356.          var _loc11_:Number = NaN;
  357.          var _loc12_:Number = NaN;
  358.          var _loc13_:Number = NaN;
  359.          var _loc14_:Number = NaN;
  360.          var _loc15_:Number = NaN;
  361.          var _loc16_:Number = NaN;
  362.          var _loc17_:Number = NaN;
  363.          var _loc18_:Number = NaN;
  364.          var _loc19_:Number = NaN;
  365.          super.layoutChrome(param1,param2);
  366.          _loc3_ = borderMetrics;
  367.          _loc4_ = _loc3_.left;
  368.          _loc5_ = _loc3_.top;
  369.          _loc6_ = getHeaderHeight();
  370.          if(_loc6_ > 0 && height >= _loc6_)
  371.          {
  372.             _loc7_ = param1 - _loc3_.left - _loc3_.right;
  373.             showTitleBar(true);
  374.             titleBar.mouseChildren = true;
  375.             titleBar.mouseEnabled = true;
  376.             _loc8_ = titleBar.graphics;
  377.             _loc8_.clear();
  378.             _loc8_.beginFill(16777215,0);
  379.             _loc8_.drawRect(0,0,_loc7_,_loc6_);
  380.             _loc8_.endFill();
  381.             titleBar.move(_loc4_,_loc5_);
  382.             titleBar.setActualSize(_loc7_,_loc6_);
  383.             mx_internal::titleBarBackground.move(0,0);
  384.             IFlexDisplayObject(mx_internal::titleBarBackground).setActualSize(_loc7_,_loc6_);
  385.             mx_internal::closeButton.visible = mx_internal::_showCloseButton;
  386.             if(mx_internal::_showCloseButton)
  387.             {
  388.                mx_internal::closeButton.setActualSize(mx_internal::closeButton.getExplicitOrMeasuredWidth(),mx_internal::closeButton.getExplicitOrMeasuredHeight());
  389.                mx_internal::closeButton.move(param1 - _loc4_ - _loc3_.right - 10 - mx_internal::closeButton.getExplicitOrMeasuredWidth(),(_loc6_ - mx_internal::closeButton.getExplicitOrMeasuredHeight()) / 2);
  390.             }
  391.             _loc9_ = 10;
  392.             _loc10_ = 10;
  393.             if(mx_internal::titleIconObject)
  394.             {
  395.                _loc11_ = Number(mx_internal::titleIconObject.height);
  396.                _loc12_ = (_loc6_ - _loc11_) / 2;
  397.                mx_internal::titleIconObject.move(_loc9_,_loc12_);
  398.                _loc9_ += mx_internal::titleIconObject.width + 4;
  399.             }
  400.             _loc11_ = titleTextField.textHeight;
  401.             _loc12_ = (_loc6_ - _loc11_) / 2;
  402.             _loc13_ = _loc3_.left + _loc3_.right;
  403.             titleTextField.move(_loc9_,_loc12_ - 1);
  404.             titleTextField.setActualSize(Math.max(0,param1 - _loc9_ - _loc10_ - _loc13_),_loc11_ + UITextField.mx_internal::TEXT_HEIGHT_PADDING);
  405.             _loc11_ = statusTextField.textHeight;
  406.             _loc12_ = (_loc6_ - _loc11_) / 2;
  407.             _loc14_ = param1 - _loc10_ - 4 - _loc13_ - statusTextField.textWidth;
  408.             if(mx_internal::_showCloseButton)
  409.             {
  410.                _loc14_ -= mx_internal::closeButton.getExplicitOrMeasuredWidth() + 4;
  411.             }
  412.             statusTextField.move(_loc14_,_loc12_ - 1);
  413.             statusTextField.setActualSize(statusTextField.textWidth + 8,statusTextField.textHeight + UITextField.mx_internal::TEXT_HEIGHT_PADDING);
  414.             _loc15_ = titleTextField.x + titleTextField.textWidth + 8;
  415.             if(statusTextField.x < _loc15_)
  416.             {
  417.                statusTextField.width = Math.max(statusTextField.width - (_loc15_ - statusTextField.x),0);
  418.                statusTextField.x = _loc15_;
  419.             }
  420.          }
  421.          else if(titleBar)
  422.          {
  423.             showTitleBar(false);
  424.             titleBar.mouseChildren = false;
  425.             titleBar.mouseEnabled = false;
  426.          }
  427.          if(controlBar)
  428.          {
  429.             _loc16_ = Number(controlBar.x);
  430.             _loc17_ = Number(controlBar.y);
  431.             _loc18_ = Number(controlBar.width);
  432.             _loc19_ = Number(controlBar.height);
  433.             controlBar.setActualSize(param1 - (_loc3_.left + _loc3_.right),controlBar.getExplicitOrMeasuredHeight());
  434.             controlBar.move(_loc3_.left,param2 - _loc3_.bottom - controlBar.getExplicitOrMeasuredHeight());
  435.             if(controlBar.includeInLayout)
  436.             {
  437.                controlBar.visible = controlBar.y >= _loc3_.top;
  438.             }
  439.             if(_loc16_ != controlBar.x || _loc17_ != controlBar.y || _loc18_ != controlBar.width || _loc19_ != controlBar.height)
  440.             {
  441.                invalidateDisplayList();
  442.             }
  443.          }
  444.       }
  445.       
  446.       public function set layout(param1:String) : void
  447.       {
  448.          if(_layout != param1)
  449.          {
  450.             _layout = param1;
  451.             if(layoutObject)
  452.             {
  453.                layoutObject.target = null;
  454.             }
  455.             if(_layout == ContainerLayout.ABSOLUTE)
  456.             {
  457.                layoutObject = new CanvasLayout();
  458.             }
  459.             else
  460.             {
  461.                layoutObject = new BoxLayout();
  462.                if(_layout == ContainerLayout.VERTICAL)
  463.                {
  464.                   BoxLayout(layoutObject).direction = BoxDirection.VERTICAL;
  465.                }
  466.                else
  467.                {
  468.                   BoxLayout(layoutObject).direction = BoxDirection.HORIZONTAL;
  469.                }
  470.             }
  471.             if(layoutObject)
  472.             {
  473.                layoutObject.target = this;
  474.             }
  475.             invalidateSize();
  476.             invalidateDisplayList();
  477.             dispatchEvent(new Event("layoutChanged"));
  478.          }
  479.       }
  480.       
  481.       override public function get viewMetrics() : EdgeMetrics
  482.       {
  483.          var _loc1_:EdgeMetrics = null;
  484.          var _loc2_:EdgeMetrics = null;
  485.          var _loc3_:Number = NaN;
  486.          var _loc4_:Number = NaN;
  487.          var _loc5_:Number = NaN;
  488.          var _loc6_:Number = NaN;
  489.          var _loc7_:Number = NaN;
  490.          var _loc8_:Number = NaN;
  491.          if(!panelViewMetrics)
  492.          {
  493.             panelViewMetrics = new EdgeMetrics(0,0,0,0);
  494.          }
  495.          _loc1_ = panelViewMetrics;
  496.          _loc2_ = super.viewMetrics;
  497.          _loc3_ = getStyle("borderThickness");
  498.          _loc4_ = getStyle("borderThicknessLeft");
  499.          _loc5_ = getStyle("borderThicknessTop");
  500.          _loc6_ = getStyle("borderThicknessRight");
  501.          _loc7_ = getStyle("borderThicknessBottom");
  502.          _loc1_.left = _loc2_.left + (isNaN(_loc4_) ? _loc3_ : _loc4_);
  503.          _loc1_.top = _loc2_.top + (isNaN(_loc5_) ? _loc3_ : _loc5_);
  504.          _loc1_.right = _loc2_.right + (isNaN(_loc6_) ? _loc3_ : _loc6_);
  505.          _loc1_.bottom = _loc2_.bottom + (isNaN(_loc7_) ? (Boolean(controlBar) && !isNaN(_loc5_) ? _loc5_ : (isNaN(_loc4_) ? _loc3_ : _loc4_)) : _loc7_);
  506.          _loc8_ = getHeaderHeight();
  507.          if(!isNaN(_loc8_))
  508.          {
  509.             _loc1_.top += _loc8_;
  510.          }
  511.          if(Boolean(controlBar) && Boolean(controlBar.includeInLayout))
  512.          {
  513.             _loc1_.bottom += controlBar.getExplicitOrMeasuredHeight();
  514.          }
  515.          return _loc1_;
  516.       }
  517.       
  518.       [Bindable("titleChanged")]
  519.       public function get title() : String
  520.       {
  521.          return _title;
  522.       }
  523.       
  524.       override public function set enabled(param1:Boolean) : void
  525.       {
  526.          super.enabled = param1;
  527.          if(titleTextField)
  528.          {
  529.             titleTextField.enabled = param1;
  530.          }
  531.          if(statusTextField)
  532.          {
  533.             statusTextField.enabled = param1;
  534.          }
  535.          if(controlBar)
  536.          {
  537.             controlBar.enabled = param1;
  538.          }
  539.          if(mx_internal::closeButton)
  540.          {
  541.             mx_internal::closeButton.enabled = param1;
  542.          }
  543.       }
  544.       
  545.       private function stage_mouseLeaveHandler(param1:Event) : void
  546.       {
  547.          if(!isNaN(regX))
  548.          {
  549.             stopDragging();
  550.          }
  551.       }
  552.       
  553.       [Bindable("titleIconChanged")]
  554.       public function get titleIcon() : Class
  555.       {
  556.          return _titleIcon;
  557.       }
  558.       
  559.       override protected function createChildren() : void
  560.       {
  561.          var _loc1_:Class = null;
  562.          var _loc2_:IStyleClient = null;
  563.          var _loc3_:ISimpleStyleClient = null;
  564.          var _loc4_:String = null;
  565.          var _loc5_:String = null;
  566.          super.createChildren();
  567.          if(!titleBar)
  568.          {
  569.             titleBar = new UIComponent();
  570.             titleBar.visible = false;
  571.             titleBar.addEventListener(MouseEvent.MOUSE_DOWN,titleBar_mouseDownHandler);
  572.             rawChildren.addChild(titleBar);
  573.          }
  574.          if(!mx_internal::titleBarBackground)
  575.          {
  576.             _loc1_ = getStyle("titleBackgroundSkin");
  577.             if(_loc1_)
  578.             {
  579.                mx_internal::titleBarBackground = new _loc1_();
  580.                _loc2_ = mx_internal::titleBarBackground as IStyleClient;
  581.                if(_loc2_)
  582.                {
  583.                   _loc2_.setStyle("backgroundImage",undefined);
  584.                }
  585.                _loc3_ = mx_internal::titleBarBackground as ISimpleStyleClient;
  586.                if(_loc3_)
  587.                {
  588.                   _loc3_.styleName = this;
  589.                }
  590.                titleBar.addChild(DisplayObject(mx_internal::titleBarBackground));
  591.             }
  592.          }
  593.          if(!titleTextField)
  594.          {
  595.             titleTextField = new UITextField();
  596.             titleTextField.selectable = false;
  597.             titleBar.addChild(titleTextField);
  598.             _loc4_ = getStyle("titleStyleName");
  599.             titleTextField.styleName = _loc4_;
  600.             titleTextField.text = title;
  601.             titleTextField.enabled = enabled;
  602.          }
  603.          if(!statusTextField)
  604.          {
  605.             statusTextField = new UITextField();
  606.             statusTextField.selectable = false;
  607.             titleBar.addChild(statusTextField);
  608.             _loc5_ = getStyle("statusStyleName");
  609.             statusTextField.styleName = _loc5_;
  610.             statusTextField.text = status;
  611.             statusTextField.enabled = enabled;
  612.          }
  613.          if(!mx_internal::closeButton)
  614.          {
  615.             mx_internal::closeButton = new Button();
  616.             mx_internal::closeButton.styleName = this;
  617.             mx_internal::closeButton.mx_internal::upSkinName = "closeButtonUpSkin";
  618.             mx_internal::closeButton.mx_internal::overSkinName = "closeButtonOverSkin";
  619.             mx_internal::closeButton.mx_internal::downSkinName = "closeButtonDownSkin";
  620.             mx_internal::closeButton.mx_internal::disabledSkinName = "closeButtonDisabledSkin";
  621.             mx_internal::closeButton.explicitWidth = mx_internal::closeButton.explicitHeight = 16;
  622.             mx_internal::closeButton.focusEnabled = false;
  623.             mx_internal::closeButton.visible = false;
  624.             mx_internal::closeButton.enabled = enabled;
  625.             mx_internal::closeButton.addEventListener(MouseEvent.CLICK,closeButton_clickHandler);
  626.             titleBar.addChild(mx_internal::closeButton);
  627.             mx_internal::closeButton.owner = this;
  628.          }
  629.       }
  630.       
  631.       [Bindable("layoutChanged")]
  632.       public function get layout() : String
  633.       {
  634.          return _layout;
  635.       }
  636.       
  637.       override public function set cacheAsBitmap(param1:Boolean) : void
  638.       {
  639.          super.cacheAsBitmap = param1;
  640.          if(cacheAsBitmap && !mx_internal::contentPane && cachePolicy != UIComponentCachePolicy.OFF && getStyle("backgroundColor"))
  641.          {
  642.             mx_internal::createContentPane();
  643.             invalidateDisplayList();
  644.          }
  645.       }
  646.       
  647.       private function closeButton_clickHandler(param1:MouseEvent) : void
  648.       {
  649.          dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
  650.       }
  651.       
  652.       private function setControlBar(param1:IUIComponent) : void
  653.       {
  654.          var _loc2_:String = null;
  655.          if(param1 == controlBar)
  656.          {
  657.             return;
  658.          }
  659.          controlBar = param1;
  660.          if(!checkedForAutoSetRoundedCorners)
  661.          {
  662.             checkedForAutoSetRoundedCorners = true;
  663.             autoSetRoundedCorners = !!styleDeclaration ? styleDeclaration.getStyle("roundedBottomCorners") === undefined : true;
  664.          }
  665.          if(autoSetRoundedCorners)
  666.          {
  667.             setStyle("roundedBottomCorners",controlBar != null);
  668.          }
  669.          _loc2_ = getStyle("controlBarStyleName");
  670.          if(Boolean(_loc2_) && controlBar is ISimpleStyleClient)
  671.          {
  672.             ISimpleStyleClient(controlBar).styleName = _loc2_;
  673.          }
  674.          if(controlBar)
  675.          {
  676.             controlBar.enabled = enabled;
  677.          }
  678.          if(controlBar is IAutomationObject)
  679.          {
  680.             IAutomationObject(controlBar).showInAutomationHierarchy = false;
  681.          }
  682.          mx_internal::invalidateViewMetricsAndPadding();
  683.          invalidateSize();
  684.          invalidateDisplayList();
  685.       }
  686.       
  687.       protected function stopDragging() : void
  688.       {
  689.          systemManager.removeEventListener(MouseEvent.MOUSE_MOVE,systemManager_mouseMoveHandler,true);
  690.          systemManager.removeEventListener(MouseEvent.MOUSE_UP,systemManager_mouseUpHandler,true);
  691.          systemManager.stage.removeEventListener(Event.MOUSE_LEAVE,stage_mouseLeaveHandler);
  692.          regX = NaN;
  693.          regY = NaN;
  694.       }
  695.       
  696.       private function titleBar_mouseDownHandler(param1:MouseEvent) : void
  697.       {
  698.          if(param1.target == mx_internal::closeButton)
  699.          {
  700.             return;
  701.          }
  702.          if(enabled && isPopUp && isNaN(regX))
  703.          {
  704.             startDragging(param1);
  705.          }
  706.       }
  707.       
  708.       override protected function initializeAccessibility() : void
  709.       {
  710.          if(Panel.mx_internal::createAccessibilityImplementation != null)
  711.          {
  712.             Panel.mx_internal::createAccessibilityImplementation(this);
  713.          }
  714.       }
  715.       
  716.       override public function styleChanged(param1:String) : void
  717.       {
  718.          var _loc2_:Boolean = false;
  719.          var _loc3_:String = null;
  720.          var _loc4_:String = null;
  721.          var _loc5_:String = null;
  722.          var _loc6_:Class = null;
  723.          var _loc7_:IStyleClient = null;
  724.          var _loc8_:ISimpleStyleClient = null;
  725.          _loc2_ = !param1 || param1 == "styleName";
  726.          super.styleChanged(param1);
  727.          if(_loc2_ || param1 == "titleStyleName")
  728.          {
  729.             if(titleTextField)
  730.             {
  731.                _loc3_ = getStyle("titleStyleName");
  732.                titleTextField.styleName = _loc3_;
  733.             }
  734.          }
  735.          if(_loc2_ || param1 == "statusStyleName")
  736.          {
  737.             if(statusTextField)
  738.             {
  739.                _loc4_ = getStyle("statusStyleName");
  740.                statusTextField.styleName = _loc4_;
  741.             }
  742.          }
  743.          if(_loc2_ || param1 == "controlBarStyleName")
  744.          {
  745.             if(Boolean(controlBar) && controlBar is ISimpleStyleClient)
  746.             {
  747.                _loc5_ = getStyle("controlBarStyleName");
  748.                ISimpleStyleClient(controlBar).styleName = _loc5_;
  749.             }
  750.          }
  751.          if(_loc2_ || param1 == "titleBackgroundSkin")
  752.          {
  753.             if(titleBar)
  754.             {
  755.                _loc6_ = getStyle("titleBackgroundSkin");
  756.                if(_loc6_)
  757.                {
  758.                   if(mx_internal::titleBarBackground)
  759.                   {
  760.                      titleBar.removeChild(DisplayObject(mx_internal::titleBarBackground));
  761.                      mx_internal::titleBarBackground = null;
  762.                   }
  763.                   mx_internal::titleBarBackground = new _loc6_();
  764.                   _loc7_ = mx_internal::titleBarBackground as IStyleClient;
  765.                   if(_loc7_)
  766.                   {
  767.                      _loc7_.setStyle("backgroundImage",undefined);
  768.                   }
  769.                   _loc8_ = mx_internal::titleBarBackground as ISimpleStyleClient;
  770.                   if(_loc8_)
  771.                   {
  772.                      _loc8_.styleName = this;
  773.                   }
  774.                   titleBar.addChildAt(DisplayObject(mx_internal::titleBarBackground),0);
  775.                }
  776.             }
  777.          }
  778.       }
  779.       
  780.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  781.       {
  782.          super.updateDisplayList(param1,param2);
  783.          layoutObject.updateDisplayList(param1,param2);
  784.          if(mx_internal::border)
  785.          {
  786.             mx_internal::border.visible = true;
  787.          }
  788.          titleBar.visible = true;
  789.       }
  790.    }
  791. }
  792.  
  793.